package com.allwees.bs.c.module.order.dto;

import com.allwees.bs.c.module.product.dto.ProductDetailsDTO;
import com.allwees.bs.c.module.product.dto.SkuDTO;
import com.allwees.core.common.util.MoneyUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 *
 *
 * @author yangylsky
 *
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class CartItemDTO implements Serializable {
	private ProductDetailsDTO product;

	// 商品SKU
	private SkuDTO sku;

	// 购买数量
	private Integer quantity;

	// 总金额
	private BigDecimal amt;

	// 原始总金额
	private BigDecimal originalAmt;

	// 商品总价
	private BigDecimal amtSku;

	// 原始 item 价格
	private BigDecimal originalAmtSku;

	// 运费
	private BigDecimal amtShipping;

	// 运费
	private BigDecimal originalAmtShipping;

	// 为了和加价兼容, 计算sku运费的时候都是用这个字段
	private BigDecimal originalAmtShippingSku;
	// 为了和加价兼容, 计算sku商品价格的时候都是用这个字段
	private BigDecimal productAmtSkuAfterAdd;


	//cash 实付金额
	private BigDecimal amtCashSku = BigDecimal.ZERO;

	//cash 实付商品金额
	private BigDecimal amtCashProductSku = BigDecimal.ZERO;

	//cash 实付运费金额
	private BigDecimal amtCashShippingSku = BigDecimal.ZERO;

	public void setOriginalAmtShippingSku(BigDecimal originalAmtShippingSku) {
		this.originalAmtShippingSku = amtShipping;
	}

	public BigDecimal amt() {
		return MoneyUtil.add(amtSku(), amtShipping());
	}

	public BigDecimal amtSku() {
		//amtSku = MoneyUtil.mul(sku.getRetailPrice(), new BigDecimal(quantity));
		amtSku = MoneyUtil.mul(sku.getPriceRetail(), new BigDecimal(quantity));
		return amtSku;
	}

	public BigDecimal amtShipping() {
		//amtShipping = MoneyUtil.mul(sku.getShippingPrice(), new BigDecimal(quantity));
		amtShipping = MoneyUtil.mul(sku.getPriceShip(), new BigDecimal(quantity));
		return amtShipping;
	}
}
